let startY=0;//手指起始目标
let moveY=0;//手指移动目标
let moveDistance=0;//移动距离
let baseIconUrl = '../../static/iconfont/personal/'
import { getPersonalBase } from '../../api/personal' 

// pages/personal/personal.js
let app =  getApp();
  
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name:'曹丽诗',
    coverTransform:'translateY(0)',
    moveDistance:null,
    animation: null,
    card_item:[
      {path:`${baseIconUrl}case.svg`,number:0,name:'病例',url:'medical/medical'},
      {path:`${baseIconUrl}family.svg`,number:0,name:'家庭成员',url:'family/family'},
      {path:`${baseIconUrl}data_log.svg`,number:0,name:'所有日记',url:'../recording/all-dairy/allDaylily'},
    ],
    // 设置列表
    list:[
      {icon:`${baseIconUrl}mdcubs.svg`,text:'家庭成员申请消息',url:'mdcubs/mdcubs'},
      {icon:`${baseIconUrl}remind.svg`,text:'手机账号',url:'phone/phone'},
      {icon:`${baseIconUrl}log.svg`,text:'开发信息',url:'log/log'},
    ],
    nvabarData: {
      showCapsule: 0, //是否显示左上角图标   1表示显示    0表示不显示
      title: '', //导航栏 中间的标题
      white: true,// 是就显示白的，不是就显示黑的。
      address:'https://img2.baidu.com/it/u=2128531598,4017373579&fm=26&fmt=auto&gp=0.jpg'
    },
    // 导航头的高度
    height: app.globalData.height * 2 + 20
  },
  toFamily(){
    wx.navigateTo({url:'family'})
  },
  toMedical(){
    wx.navigateTo({url:'medical'})
  },
  onLoad(){
    this.getPersonalBase()

  },
  onShow: function () {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        // 当前页面的 tabBar 索引
        active: 4
      })
    }
  },

  toNext(event){
    let url = event.currentTarget.dataset.path
    console.log(url)
    wx.navigateTo({url})
  },

  // 
  getPersonalBase(){
    let that = this
    getPersonalBase()
      .then(res=>{
        if(res.State){
          let { base_info } =res;
          let card_item = that.data.card_item
          card_item[0].number = base_info.disease_history_number
          card_item[1].number = base_info.family_number
          card_item[2].number = base_info.diary_number
          this.setData({ base_info, card_item })
        }
      })
  }
})